import requests
 
class APIRequester:
    def __init__(self, base_url, headers,token):
        self.session = requests.Session()
        self.session.headers.update(headers)
        self.base_url = base_url
        self.token = token
    
    def get(self, endpoint):
        url = f"{self.base_url}/{endpoint}"
        return self.session.get(url)
    
    def post(self, endpoint, data):
        url = f"{self.base_url}/{endpoint}"
        return self.session.post(url, json=data)
 
# # 使用封装后的类进行请求
# api = APIRequester('https://api.example.com', {
#     'User-Agent': 'My User Agent 1.0',
#     'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
# })
# response = api.get('data')
# print(response.text)